import { useRequire } from "@/api/instance";
import { IndexItem, IndexItemResult } from "$/elasticsearch-client";

export const clientIndexListApi = (id: string) => {
  return useRequire<IndexItemResult>("/api/client/index/list", {
    id
  });
};

export const clientIndexGetApi = (id: string, index: string) => {
  return useRequire<IndexItem>("/api/client/index/get", {
    id,
    index
  });
};

export const clientIndexCreateApi = (id: string, data: string) => {
  return useRequire<string>("/api/client/index/create", {
    id,
    data
  });
};

export const clientIndexUpdateApi = (id: string, index: string, data: string) => {
  return useRequire<string>("/api/client/index/update", {
    id,
    index,
    data
  });
};

export const clientIndexDeleteApi = (id: string, indexIds: Array<string>) => {
  return useRequire<string>("/api/client/index/delete", {
    id,
    indexIds
  });
};

export const clientIndexAliasAddApi = (id: string, index: string, alias: string) => {
  return useRequire<string>("/api/client/index/alias/add", {
    id,
    index,
    alias
  });
};

export const clientIndexAliasRemoveApi = (id: string, index: string, alias: string) => {
  return useRequire<string>("/api/client/index/alias/remove", {
    id,
    index,
    alias
  });
};
